<?php
namespace App\Storage;

use EasySwoole\Component\Singleton;

class Avatar {

    protected $avatar;
    use Singleton;

    function __construct()
    {

    }

    /**
     * @return mixed
     */
    public function getAvatar() {
        return $this->avatar;
    }

    /**
     * @param int $id
     * @param string $sex
     */
    public function setAvatar($sex = 'm') {
        $avatar = '/images/avatar/';
        if ($sex == 'f') {
            $avatar .= 'f_';
        } elseif($sex == 'm') {
            $avatar .= 'm_';
        }
        $avatar .= mt_rand(1,5);
        $avatar .= '.jpg';
        $this->avatar = $avatar;
        unset($avatar);
    }

}